package action.chap6;

import java.util.stream.IntStream;

public class Demo642 {
    public static void main(String[] args) {

    }
    public boolean isPrime(int candidate) {
        return IntStream.range(2, candidate)
                .noneMatch(i -> candidate % i == 0);
    }
    public boolean isPrimeTwo(int candidate) {
        int candidateRoot = (int) Math.sqrt((double) candidate);
        return IntStream.rangeClosed(2, candidateRoot)
                .noneMatch(i -> candidate % i == 0);
    }
}
